function submit() {
  $.ajax({
    type: "POST",
    url: "/api/order/submit",
    
    data: {
      addressId: 214,
      couponId: 10,
      postscript: "888888888",
    },
    success: function (res) {
        console.log(res);
        var htmlStr = template("tpl-info", res.data.orderInfo);
        var htmlStr2 = template("tpl-total", res.data.orderInfo);
        var htmlStr3 = template("tpl-pay", res.data.orderInfo);
        $('.order-info').html(htmlStr)
        $('.total').html(htmlStr2)
        $(".pay-fee").html(htmlStr3);
        console.log($("#a-time"));
        $("#a-time").html(formatDate());
    },
  });
}
submit();
$.ajax({
  type: "GET",
  url: "/api/cart/index",
  
  success: function (res) {
    console.log(res);
    var htmlStr = template("tpl-goods", res.data);
    $(".goods").html(htmlStr);
    
    $.each($(".item"), function (i, ele) {
      if ($(ele).attr("data-checked") == 0) {
        $(ele).hide();
      }
    });
  },
});

$.ajax({
  type: "GET",
  url: "/api/cart/checkout",
  success: function (res) {
    console.log(res);
    var htmlStr = template("tpl-address", res.data.checkedAddress);
    $(".address").html(htmlStr);
  },
});
function formatDate(){
	var date = new Date();

	var year = date.getFullYear(),
		month = date.getMonth()+1,//月份是从0开始的
		day = date.getDate(),
		hour = date.getHours(),
		min = date.getMinutes(),
		sec = date.getSeconds();
	var newTime = year + '-' +
				(month < 10? '0' + month : month) + '-' +
				(day < 10? '0' + day : day) + ' ' +
				(hour < 10? '0' + hour : hour) + ':' +
				(min < 10? '0' + min : min) + ':' +
				(sec < 10? '0' + sec : sec);

	return newTime;			
}
console.log(formatDate());
